package cn.codeforfun.machine;

import cn.codeforfun.base.BaseController;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author wangbin
 */
@RestController
@RequestMapping("/machine")
@CrossOrigin
public class MachineController extends BaseController<Machine, MachineService> {
    @Resource
    private MachineService machineService;

    public MachineController(MachineService service) {
        super(service);
    }

    @PostMapping("/changePassword/{id}")
    public void changePassword(@RequestBody Map<String, String> param, @PathVariable String id) {
        String password = param.get("password");
        if (ObjectUtils.isEmpty(password)) {
            throw new RuntimeException("密码不能为空");
        }
        machineService.changePassword(id, password);
    }


}
